#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <string.h>

// int fscanf(FILE *restrict stream,  const char *restrict format, ...);
// int fprintf(FILE *restrict stream, const char *restrict format, ...);
// int sprintf(char *restrict str, const char *restrict format, ...);

// int main()
// {
//     int a, b;
//     FILE *fp = fopen("scanf-input.txt", "r");

//     while (fscanf(fp, "%d %d", &a, &b) != EOF)
//     {
//         printf("a=%d b=%d\n", a, b);
//         // sleep(3);
//     }

//     return 0;
// }

// int main()
// {
//     char name[32];
//     int age;
//     int score;

//     FILE *fp = fopen("students.txt", "r");

//     while (fscanf(fp, "%s %d %d", name, &age, &score) != EOF)
//     {
//         printf("name=%s age=%d score=%d\n", name, age, score);
//     }

//     return 0;
// }

typedef struct Studnet
{
    char name[32];
    int age;
    int score;
    char class[6];
} Student_t, Student_p;

int main()
{
    Student_t students[10];
    memset(students, 0, sizeof(students));

    FILE *fp = fopen("students.txt", "r");

    int i = 0;
    while (fscanf(fp, "%s %d %d", students[i].name, &students[i].age, &students[i].score) != EOF)
    {
        // printf("name=%s age=%d score=%d\n", name, age, score);
        i++;
    }

    FILE *fp1 = fopen("students-output.txt", "a");

    for (int i = 0; i < 10; i++)
    {
        strcpy(students[i].class, "GZ2528");
        fprintf(fp1, "name=%s age=%d score=%d class=%s\n", students[i].name, students[i].age, students[i].score, students[i].class);
    }

    return 0;
}